package com.pic.mgt.monitor.check;

import java.io.File;

import com.pic.mgt.log.IgxLog;
import com.pic.mgt.monitor.WrongUnitFormatException;

public class SimpleUnitFormatChecker implements UnitFormatChecker {	
	private File confirmationFile;
	private FormatCheck[] checks;
	
	public SimpleUnitFormatChecker(FormatCheck ... checkers) {
		this.checks = checkers;
	}
	
	public void check(File confirmationFile)
								throws WrongUnitFormatException {
		this.confirmationFile = confirmationFile;
		
		try {
			for (FormatCheck check : this.checks) {
				check.check(confirmationFile.getName());
			}
		} catch (WrongUnitFormatException e) {
			// ********************** Log **********************
			IgxLog.messageDetailsLog.error(this, e.getMessage());
			// ********************** Log **********************
			
			throw e;
		}
	}
}
